package com.szr.leex.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import com.szr.leex.po.user.LocalAuth;
import com.szr.leex.po.user.Role;
import com.szr.leex.po.user.User;
import com.szr.leex.service.user.LocalAuthService;
import com.szr.leex.service.user.UserService;

/**
 * Created by WangChen on 2018/10/16 15:29.
 */
@Controller
public class HomeController extends BaseController {

    @Autowired
    private UserService userService;

    @Autowired
    private LocalAuthService localAuthService;

    @GetMapping({"/", "/index", "/home"})
    public String index(){
        return "index";
    }

    @GetMapping("/login")
    public String login(){
        return "login";
    }

    @GetMapping("/register")
    public String register(){
        return "register";
    }

    @PostMapping("/register")
    public String doRegister(/*User user*/String username, String password, String nickname){
        userService.doRegister(username, password, nickname);

//        if ()
//            return "redirect:register?error";
        return "redirect:register?success";
    }

}
